#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <iomanip>


//需要添加精度控制，如果不添加精度控制会自动按照小数点后面6位输出，如果添加则不是
using namespace std;
using LL = long long;
const int N = 1e5 + 10;
double eps = 1e-6;

int n;
double t[N], x[N];

double check(double limit){
    if(t[1] > limit) return -1;
    double left = 0, right = 1e9;
    for(int i = 1; i <= n; i ++){
        if(t[i] > limit) return -1;
        double tl = max(0.0, x[i] + t[i] - limit), tr = limit + x[i] - t[i];
        if(tl > right || tr < left) return -1;
        left = max(tl, left), right = min(right, tr);
        if(left > right) return -1;
    }
    return left;
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        cin >> n;
        for(int i = 1; i <= n; i ++) cin >> x[i];
        for(int i = 1; i <= n; i ++) cin >> t[i];

        double l = 0, r = 1e9;
        double ans = 0;
        while(r - l > 1e-7){
            double mid = (l + r) / 2.0;
            double t = check(mid);

            if(t != -1){
                r = mid;
                ans = t;
            }else{
                l = mid;
            }
        }
 
        cout << setprecision(7) << ans << '\n';
    }



    return 0;
}